#ifndef VIDEOPLUGIN_H
#define VIDEOPLUGIN_H

#include "audioplayer.h"
#include <QObject>
#include <Maestro/mcplugins.h>
#include <phonon>

class AudioPlugin : public FileSelectionInterface {
    Q_OBJECT
    Q_INTERFACES(MenuItemInterface)
    Q_INTERFACES(FileSelectionInterface)
public:
    AudioPlugin();
    QString getName();
    QIcon getImage();
    QIcon getIcon(MediaFile * mediaFile);
    QStringList getExtensions();
    void test();
    QWidget * getInterface();
    void setMediaFile(MediaFile * mediaFile);
    void setMediaQueue(QList<MediaFile *> * files, int start=0);
    bool isPlaying();
    bool setSlider(Phonon::SeekSlider * slider);

public slots:
    void play();
    void fastForward();
    void rewind();
    void stop();
    void setVolume(int);
    void setShuffleState(bool shuffleState);
    void setRepeatState(int repeatState);
    void next();
    void previous();
    void stateChange(Phonon::State oldS, Phonon::State newS);
    void mediaSourceChanged(Phonon::MediaSource source);

signals:
    void stateChanged(bool playing);
    void error(QString errorMessage);
    void fileChanged(QString name, int index, int total);
    void fileChanged(MediaFile * file);
private:
    void determineSong();
    int index;
    AudioPlayer * player;
    Phonon::MediaObject * mediaObject;
    QList<Phonon::MediaSource> queue;
    QList<MediaFile *> * sourceQueue;
    QList<Phonon::MediaSource> tmpQueue;
    Phonon::AudioOutput *audioOutput;
    QTimer * ffTimer;
    QTimer * rwTimer;
    bool acceleratedPlay;
    int repeat;
    bool shuffle;
private slots:
    void ff();
    void rw();
    void aboutToFinish();
    void stateChanged(Phonon::State newS, Phonon::State oldS);

};

#endif // VIDEOPLUGIN_H
